how to solve 'exception from hresult: 0x80040402' in asp.net framework using c# ?

MAZOOTH 0 Reputation points
2024-08-04T03:55:40.8433333+00:00

when i open and create asp.net framework using c# project, it throws exception from hresults: 0x80040402 exception. How to solve this?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,927 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,512 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,205 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,029 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 31,326 Reputation points Microsoft Vendor
    2024-08-05T02:40:28.0266667+00:00

    Hello @MAZOOTH ,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    It’s a known issue and can be easily reproduced in some specific version of Visual Studio 2022, for example Visual Studio Community 2022 Preview(17.11.0 Preview 4.0).

    User's image

    Here are some workarounds currently:

    1. When you are going to create an ASP .NET (.NET Framework) project, try to uncheck the Place solution and project in the same directory option.

    User's image

    1. When you launch VS and prepare to create a new project(ASP .NET project), don’t directly create it in Start/create a new project page, instead, clicking Continue without code, File, New, Project to create it.

    User's image

    User's image

    Here’s the feedback ticket: HRESULT: 0X80040402 when creating a new Web Forms Project of this issue, please kindly check it and follow that ticket for any latest information about the fix.

    Thanks for your understanding, if you have any further concerns, please feel free to let us know :)

    Have a nice day.

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    5 people found this answer helpful.

  2. Ahad Karimi Moridani 80 Reputation points
    2024-08-04T04:31:10.6233333+00:00

    Hi,
    Go to Build > Clean Solution and then Build > Rebuild Solution in Visual Studio. This can help resolve issues caused by corrupted build artifacts.

    0 comments No comments

  3. Albert Kallal 5,256 Reputation points
    2024-08-05T01:09:24.3533333+00:00

    We probably need some of your markup and code here to really guess what is going on.

    However, that x800 error often suggests a bit size miss-match, and especially the case when you reference 3rd party library code that is NOT managed. (non .net code).

    So, if your project is using ANY CPU, try a changing over to x32, or x64 bits, do a re-build, and see if the error occurs. In other words, force the project to run as x32 bits, or x64 bits, and don't use ANY cpu for the project settings.

    Beyond the above "general" suggestion, then we need some sample code that re-produces the error, else we all just guessing here. So, a minimal and re-producible example would help a lot here for troubleshooting.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.